<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model="msg" />
        <div v-for="(item,index) in arr" :key="index ">{{item}}</div>
        <button @click="handle1">变异</button>
        <button @click="handle2">替换</button>
    </div>
    <script src="../vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: '',
                arr: ['Tom', 'Jerry', 'Merry'],
            },
            methods: {
                handle1: function() {
                    this.arr.push(this.msg);
                },
                handle2: function() {
                    this.arr = this.arr.slice(0, 4);
                },
            },
        });
    </script>
</body>

</html>